public class Student {
    private String name;
    public int age;
    public String gender;

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    private void eat(){
        System.out.println(this.name+"正在吃饭ing...");
    }
    public void toEat(){
        this.eat();
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", gender='" + gender + '\'' +
                '}';
    }
}
class Test{
        public static void main(String[] args) {
            Student student1 = new Student();
            student1.age = 10;
            student1.gender = "男";
            student1.setName("张三");//初始化name
            System.out.println(student1.getName());//拿到name
            student1.toEat();
            //打印整个类
            System.out.println(student1.toString());
        }

}
